package com.example.nioprc.infrastructure.serializer;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;


public class JsonSerializer implements Serializer{
    private final ObjectMapper objectMapper=new ObjectMapper();


    @Override
    public byte[] serialize(Object obj) throws IOException {
        return objectMapper.writeValueAsBytes(obj);
    }

    @Override
    public <T> T deserialize(byte[] bytes, Class<T> clazz) throws IOException {
        return objectMapper.readValue(bytes,clazz);
    }
}
